from rest_framework.mixins import CreateModelMixin
from rest_framework.generics import ListCreateAPIView
from apps.meiduo_admin.utils import PageNum

from apps.users.models import User
from apps.meiduo_admin.serializers.user import UserModelSerializer



class UserAPIView(ListCreateAPIView):


    def get_queryset(self):

        keyword=self.request.query_params.get('keyword')

        if keyword:
            return User.objects.filter(username__contains=keyword)

        return User.objects.all()

    serializer_class = UserModelSerializer

    pagination_class = PageNum